package com.hsj.goldstore.mvp.present.fragment;

import com.hsj.goldstore.base.BaseMvpPresent;
import com.hsj.goldstore.base.ResultCallback;
import com.hsj.goldstore.bean.GoodsBean;
import com.hsj.goldstore.bean.LoginBean;
import com.hsj.goldstore.mvp.model.GoodsTypeModel;
import com.hsj.goldstore.mvp.view.fragment.GoodsTypeView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/3/26.
 */

public class GoodsTypePresent extends BaseMvpPresent<GoodsTypeView> implements IGoodsTypePresent {
    private List<GoodsBean> list;
    private GoodsTypeModel model;

    public GoodsTypePresent() {
        model = new GoodsTypeModel();
    }

    @Override
    public void initData() {
        checkViewAttach();
        model.getGoodsList(mvpView.getType(), new ResultCallback() {
            @Override
            public void onSuccess(Object data, int code, String msg) {
                mvpView.setData((List<GoodsBean>) data);
            }

            @Override
            public void onFalure(int code, String err) {
                mvpView.showError(err);
            }
        });

//        list = new ArrayList<>();
//        if (mvpView.getType() == 0) {
//            list.add(new GoodsBean());
//        } else if (mvpView.getType() == 1) {
//            list.add(new GoodsBean());
//            list.add(new GoodsBean());
//            list.add(new GoodsBean());
//            list.add(new GoodsBean());
//        } else {
//
//        }
//        mvpView.setData(list);
    }

    @Override
    public void refresh() {
        mvpView.refreshComplete();
    }

    @Override
    public void loadMore() {
        mvpView.refreshComplete();
        mvpView.noMore(true);
    }
}
